#include "LogicClear.h"

Display LogicClear::clearTask() {
	
	string statusMessage;
	Data::DataFeedback dataFeedback;
	vector<Task> tasks;
	vector<Task> emptyDisplay;

	if( _data->getCapacity() == 0 ) {
		statusMessage = FILE_EMPTY;
	} else {
		dataFeedback = _data->executeClear();

		if( dataFeedback == Data::SUCCESS ) {
			_data->getAll(tasks);
			_writer->write(tasks);
			statusMessage = CLEAR_SUCCESS_MESSAGE;
		} else {
			statusMessage = CLEAR_ERROR_MESSAGE;
			// log errors
		}
	}

	_display = Display( statusMessage, emptyDisplay );

	return _display;
}

const string LogicClear::CLEAR_SUCCESS_MESSAGE = "File Contents Cleared";

const string LogicClear::CLEAR_ERROR_MESSAGE = "File Is Empty";